#include<iostream>
#include<cmath>
using namespace std;
int t, n, m, l, V;
int d[100001], v[100001], a[100001], p[100001];
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin >> t;
    while(t--){
        int ans=0;
        bool A=1, B=1;
        cin >> n >> m >> l >> V;
        for(int i=1;i<=n;i++){
            cin >> d[i] >> v[i] >> a[i];
            if(a[i]!=0) A=0;
            if(a[i]<=0) B=0;
        }
        for(int i=1;i<=m;i++){
            cin >> p[i];
        }
        if(A){
            for(int i=1;i<=n;i++){
                if(d[i]<=p[m]&&v[i]>V) ans++;
            }
            cout << ans << " ";
            if(ans==0) cout << m;
            else cout << m-1;
        }
        else if(B){
            for(int i=1;i<=n;i++){
				if(d[i]<=p[m]){
					double fv=sqrt(v[i]*v[i]+2*a[i]*(p[m]-d[i]));
					if(fv>V) ans++;
				}
            }
            cout << ans << " ";
            if(ans==0) cout << m;
            else cout << m-1;
        }
        else{
            cout << 1 << " " << 1;
        }
        cout << "\n";
    }
    return 0;
}
